jQuery(document).ready(function($) {
    var cookie = JSON.parse($.cookie('bjou_student'));
	$.ajax({
		type: 'GET',
		url: 'api/v1/check'

	}).done(function (data, textStatus, jqXHR) {

	}).fail(function (jqXHR, textStatus, errorThrown) {
        window.location = '../index.html';
	});

    $('#welcome').html("欢迎," + cookie.studentName + "同学")
	$('#logout').on('click', function (event) {
		event.preventDefault();
		$.ajax({
			data: {},
			timeout: 1000,
			type: 'POST',
			url: '../logout'

		}).done(function(data, textStatus, jqXHR) {
			window.location = '../index.html';
		}).fail(function(jqXHR, textStatus, errorThrown) {
		    window.location = '../index.html';
		});
	});


});


layui.use(['form', 'element'], function(){
    var $ = layui.jquery
    ,form = layui.form
    ,element = layui.element;

    var cookie = JSON.parse($.cookie('bjou_student'));
    $.ajax({
        type: 'GET',
        url: 'api/v1/status/' + cookie.studentID
    }).done(function (data, textStatus, jqXHR) {
        $("#photo").attr('src', "../photos/"+data.sfzh.toUpperCase()+".jpg")
        $("#xm").html(data.xm)
        $("#xh").html(data.xh)
        $("#yddh").html(data.yddh)
        $("#dzzczh").html(data.dzzczh)
        $("#byndxq").html(data.byndxq)
        $("#zymc").html(data.zymc)
        $("#zyccmc").html(data.zyccmc)
        $("#gzh").html(data.gzh)
        $("#bdm").html(data.bdm)
        $("#bmc").html(data.bmc)
        $("#xjztmc").html(data.xjztmc)
        $("#rxnd").html(data.rxnd)
        $("#rxxqmc").html(data.rxxqmc)
    }).fail(function (jqXHR, textStatus, errorThrown) {
    });

});